// README
//
// There are two steps to adding a property:
//
// 1. Create a member variable to store your property
// 2. Add the get_ and set_ accessors for your property
//
// Remember that both are case sensitive!


/// <reference name="MicrosoftAjaxTimer.debug.js" />
/// <reference name="MicrosoftAjaxWebForms.debug.js" />
/// <reference name="AjaxControlToolkit.ExtenderBase.BaseScripts.js" assembly="AjaxControlToolkit" />


Type.registerNamespace('ReserveSocietyControls');

ReserveSocietyControls.ImageProgressControlBehavior = function(element) {
    ReserveSocietyControls.ImageProgressControlBehavior.initializeBase(this, [element]);

    this._AssociatedUpdatePanelId = null;
}
ReserveSocietyControls.ImageProgressControlBehavior.prototype = {
    initialize : function() {
        ReserveSocietyControls.ImageProgressControlBehavior.callBaseMethod(this, 'initialize');
        
        this._beginRequestHandler = Function.createDelegate(this, this.begin);
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(this._beginRequestHandler);  
        this._pageLoadedHandler = Function.createDelegate(this, this.end);
        Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(this._pageLoadedHandler);  
    },

    dispose : function() {
        // TODO: Add your cleanup code here

        ReserveSocietyControls.ImageProgressControlBehavior.callBaseMethod(this, 'dispose');
        Sys.WebForms.PageRequestManager.getInstance().remove_beginRequest(this._beginRequestHandler);  
        Sys.WebForms.PageRequestManager.getInstance().remove_pageLoaded(this._pageLoadedHandler);  
    },

    get_AssociatedUpdatePanelId : function() {
        return this._AssociatedUpdatePanelId;
    },

    set_AssociatedUpdatePanelId : function(value) {
        this._AssociatedUpdatePanelId = value;
    },
    
    begin : function(sender, e)
    {
        var curElem = e.get_postBackElement();
        var show = false;
        while(!show && curElem)
        {
            if(curElem.id == this.get_AssociatedUpdatePanelId())
            {
                show = true;   
            }
            else
            {
                curElem = curElem.parentNode;
            }
        }
        if(show)
        {
            this.get_element().style.visibility = 'visible';
        }
    },
    
    end : function(sender, e)
    {
        this.get_element().style.visibility = 'hidden';
    }
}
ReserveSocietyControls.ImageProgressControlBehavior.registerClass('ReserveSocietyControls.ImageProgressControlBehavior', AjaxControlToolkit.BehaviorBase);
